package com.xenione.libs.swipemaker;

import ohos.agp.components.AttrSet;
import ohos.agp.components.StackLayout;
import ohos.app.Context;

/**
 * Created on 06/04/16.
 */
public abstract class AbsCoordinatorLayout extends StackLayout implements SwipeLayout.OnTranslateChangeListener {

    private SwipeLayout mForegroundView;
    private int mStartPosition = 0;

    public Runnable initializeViews = new Runnable() {
        @Override
        public void run() {
            mForegroundView.translateTo(mStartPosition);
        }
    };

    public AbsCoordinatorLayout(Context context) {
        super(context);
    }

    public AbsCoordinatorLayout(Context context, AttrSet attrs) {
        super(context, attrs);
    }

    public AbsCoordinatorLayout(Context context, AttrSet attrs, String defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

//    @TargetApi(Build.VERSION_CODES.LOLLIPOP)
//    public AbsCoordinatorLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
//        super(context, attrs, defStyleAttr, defStyleRes);
//    }

//    @Override
//    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
//        super.onLayout(changed, left, top, right, bottom);
//        doInitialViewsLocation();
//    }

    @Override
    protected void onRtlChanged(LayoutDirection layoutDirection) {
        super.onRtlChanged(layoutDirection);
    }

    //public abstract void doInitialViewsLocation();

    public void startWith(int position) {
        mStartPosition = position;
        mForegroundView.startWith(position);
    }

    public void sync(SwipeLayout foregroundView) {
        mForegroundView = foregroundView;
        mForegroundView.translateTo(mStartPosition);
    }
}
